/*
 * 添加订单类型交易
 * 参数   交易码：trancode=15132
 * 
 */

package org.ccams.tran;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.ccams.domain.TOrdertype;
/**
 * 添加订单类型交易
 * @author liuguangshuai@gmail.com
 * @系统名称：定制化辅助生成制造系统
 * @时间：Sep 16, 2008
 */
public class Tran15132 extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String ordername = (String) request.getParameter("ordername");
		String description = (String) request.getParameter("description");
		String demandClassCode = (String) request.getParameter("demandClassCode");
		String orderdeptId = (String)request.getParameter("orderdeptId");
		Integer transferToShipping = Integer.parseInt(request.getParameter("transferToShipping"));
		Integer isabroadorder = Integer.parseInt(request.getParameter("isabroadorder"));
		ordername = (ordername != null) ? ordername : "";
		description = (description != null) ? description : "";
		demandClassCode = (demandClassCode != null) ? demandClassCode : "";		
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		boolean success = false;
		String message = "";
		TOrdertype t = new TOrdertype();
		t.setDescription(description);
		t.setDemandClassCode(demandClassCode);
		t.setOrdername(ordername);
		t.setIsabroadorder(isabroadorder);
		t.setOrderdeptId(orderdeptId);
		t.setTransferToShipping(transferToShipping);		
		t.setState(0);
		int i = getCcamsService().getTordertypeDao().insert(t);
		if (i == 1) {
			success = true;
			message = "订单类型添加成功";
		} else {
			success = false;
			message = "订单类型添加失败";
		}
		jsonMap.put("success", success);
		jsonMap.put("message", message);
		json.putAll(jsonMap);
	}
}
